from datetime import date, datetime

from litestar.contrib.sqlalchemy.base import UUIDAuditBase
from sqlalchemy import String
from sqlalchemy.orm import Mapped, mapped_column


class User(UUIDAuditBase):
    __tablename__ = "user"

    user_name: Mapped[str] = mapped_column(String(50), nullable=False)
    is_admin: Mapped[bool] = mapped_column(default=False)
    is_active: Mapped[bool] = mapped_column(default=True)
    hashed_password: Mapped[str] = mapped_column(String(255), nullable=True)
    nick_name: Mapped[str] = mapped_column(String(50), nullable=True)
    email: Mapped[str] = mapped_column(String(50), nullable=True)
    phone: Mapped[str] = mapped_column(String(50), nullable=True)
    sex: Mapped[str] = mapped_column(String(10), default="male")
    birthday: Mapped[date] = mapped_column(nullable=True)
    login_count: Mapped[int] = mapped_column(default=0)
    last_login_time: Mapped[datetime] = mapped_column(nullable=True)
    last_login_ip: Mapped[str] = mapped_column(String(50), nullable=True)
